package com.limit.annotation;


import com.limit.enums.RateLimitStrategyEnum;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Inherited;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * 漏桶算法限流
 */
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.METHOD, ElementType.TYPE})
@Inherited
@Documented
public @interface LeakyBucketLimit {

    /**
     * 漏桶最大容量
     */
    long leakyCapacity() default 10L;

    /**
     * 漏桶滴水频率(秒)
     * 默认每秒漏1滴水
     */
    int dripRate() default 1;

    /**
     * 限流策略，默认为方法策略
     * <p>方法策略-> key为：rateLimit:METHOD_NAME:IP</p>
     * IP策略-> key为：rateLimit:IP
     *
     * @return RateLimitStrategyEnum 限流策略枚举
     */
    RateLimitStrategyEnum[] strategy() default {RateLimitStrategyEnum.METHOD, RateLimitStrategyEnum.USER};


}
